<template>
  <div>
    <!-- 顶部固定导航条 -->

    <div class="jobWanted_header">
      <div class="container">
        <div class="jobWanted_header_top">
          <div class="jobWanted_title">
            <h2>技术</h2>
          </div>
          <div class="jobWanted_btn">
            <router-link tag="div" to="/purpose" class="btn_one"></router-link>
            <!-- <div class="btn_tow"></div> -->
          </div>
        </div>
        <div class="jobWanted_header_bottom">
          <div class="job_bottom_lf">
            <h3 class="con">直招</h3>
          </div>
          <div class="job_bottom_ri" v-show="jobs">
            <div class="job_list">
              <!-- <div class="job_item"><span>全国</span></div>
              <div class="job_item"><span>公司</span></div> -->
              <van-dropdown-menu active-color="#ff4a23">
                <van-dropdown-item v-model="value1" :options="option1" />
                <van-dropdown-item v-model="value2" :options="option2" />
              </van-dropdown-menu>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="jobWanted_header_ti"></div>
    <!-- 顶部固定导航条 END-->

    <div class="container">
      <!-- 广告1 -->
      <div class="jobW_advertising">
        <div class="jobW_imgs">
          <div class="swiper">
            <van-swipe
              class="my-swipe"
              :autoplay="3000"
              indicator-color="white"
            >
              <van-swipe-item v-for="item in bannerLists" :key="item.Id">
                <router-link
                  tag="div"
                  :to="{ name: 'atising', query: { id: item.name } }"
                >
                  <img :src="item.srcs" alt="" />
                </router-link>
              </van-swipe-item>
              <template #indicator>
                <div class="custom-indicator"></div>
              </template>
            </van-swipe>
          </div>
        </div>
      </div>

      <!-- 广告1 END-->

      <!--选项卡  -->

      <div
        class="jobW_card"
        v-for="item in newlex()"
        :key="item.id"
        @click="books(item.id)"
      >
        <div class="jobW_card_title">
          <div class="title_text">
            <h3>{{ item.title }}</h3>
            <div class="paric">
              {{ item.paric }}
              <div class="state">
                <h4>{{ item.state }}</h4>
              </div>
            </div>
          </div>
          <div class="jobW_card_list">
            <div class="jobW_card_item" v-for="tx in item.text" :key="tx">
              {{ tx }}
            </div>
          </div>
          <div class="jobW_company">
            <div class="company_mes">
              <div class="compay_items" v-for="com in item.compay" :key="com">
                {{ com }}
              </div>
            </div>
            <div class="place">{{ item.place }}</div>
          </div>
        </div>
      </div>

      <!--选项卡 END -->
    </div>

    <!-- 内容 -->
    <!-- 内容 END-->

    <!-- 底部固定导航栏 -->
    <div class="shroud">
      <div class="container container_ji">
        <div class="shroudPanel">
          <div class="icon">
            <router-link to="/home" tag="div" class="iconrun"></router-link>
            <div class="img">
              <img
                src="../assets/imgs/src_assets_img_tab_tab_cv_normal.png"
                alt=""
              />
            </div>
            <span>首页</span>
          </div>
          <div class="icon">
            <router-link to="/jobwant" tag="div" class="iconrun"></router-link>
            <div class="img">
              <img
                src="../assets/imgs/src_assets_img_tab_tab_job_selected.png"
                alt=""
              />
            </div>
            <span>求职</span>
          </div>
          <div class="icon">
            <router-link to="/curr" tag="div" class="iconrun"></router-link>
            <div class="img">
              <img
                src="../assets/imgs/src_assets_img_tab_tab_lesson_normal.png"
                alt=""
              />
            </div>
            <span>课程</span>
          </div>
          <div class="icon">
            <router-link to="/message" tag="div" class="iconrun"></router-link>
            <div class="img message">
              <img
                src="../assets/imgs/src_assets_img_tab_tab_message_normal.png"
                alt=""
              />
              <ul class="list_message">
                <!-- <div class="message_sum">99+</div> -->
              </ul>
            </div>
            <span class="con">消息</span>
          </div>
          <div class="icon">
            <router-link to="/personal" tag="div" class="iconrun"></router-link>
            <div class="img">
              <img
                src="../assets/imgs/src_assets_img_tab_tab_me_normal.png"
                alt=""
              />
            </div>
            <span>我</span>
          </div>
        </div>
      </div>
    </div>
    <div class="shr"></div>
    <!-- 底部固定导航栏 END-->

    <!-- 未登录提示 -->
    <div class="aasi">
      <van-dialog
        v-model="show"
        title="标题"
        message="请先登录再查看内容"
        show-cancel-button
        round-button
        confirm-button-text="跳转登录页面"
        @confirm="loginto"
        confirm-button-color="#5c94f5"
      >
      </van-dialog>
    </div>
  </div>
</template>

<script>
import { getJobwantJsonData } from "../api/jobwant.js";
export default {
  data() {
    return {
      bannerLists: null,
      jcardLists: null,
      jcls: null,
      jobs: true,
      value1: 0,
      value2: 0,
      show: false,
      option1: [
        { text: "全国", value: 0 },
        { text: "东莞", value: 1 },
        { text: "广州", value: 2 },
        { text: "深圳", value: 3 },
        { text: "佛山", value: 4 },
      ],
      option2: [
        { text: "公司", value: 0 },
        { text: "魔芋信息技术", value: 1 },
        { text: "字节跳动", value: 2 },
      ],
    };
  },
  methods: {
    getBannerListsFun() {
      getJobwantJsonData().then((data) => {
        this.bannerLists = data.bannerLists;
      });
    },
    getJcardListsFun() {
      getJobwantJsonData().then((data) => {
        this.jcardLists = data.jcardLists;
      });
    },
    adver() {
      this.$router.push("/atising", (this.$router.query.id = { id: "one" }));
    },
    newlex() {
      if (this.jcardLists) {
        if (this.option1[this.value1].text == "全国") {
          if (this.option2[this.value2].text == "公司") {
            return this.jcardLists;
          } else {
            let firm = this.option2[this.value2].text;
            return this.jcardLists.filter((item) => item.compay[0] == firm);
          }
        } else {
          if (this.option2[this.value2].text == "公司") {
            let places = this.option1[this.value1].text;
            return this.jcardLists.filter((item) => item.place == places);
          } else {
            let places = this.option1[this.value1].text;
            let firm = this.option2[this.value2].text;
            return this.jcardLists
              .filter((item) => item.place == places)
              .filter((item) => item.compay[0] == firm);
          }
        }
      }
    },
    books(id) {
      console.log(id);
      localStorage.setItem("ids", id);
      let token = localStorage.getItem("token");
      if (!token) {
        this.show = true;
        return;
      } else {
        this.$router.push("bookmark");
      }
    },
    loginto(){
      this.$router.push("loginto")
    }
  },
  created() {
    this.getBannerListsFun();
    this.getJcardListsFun();
  },
  // watch: {
  //   value1: function () {
  //     console.log(this.option1[this.value1].text);
  //   },
  //   value2: function () {
  //     console.log(this.option2[this.value2].text);
  //   },
  // },
};
</script>

<style lang="scss" scoped>
// 弹窗内容样式
.aasi ::v-deep .van-dialog__message{
  font-size: 20px;
  padding: 50px 60px;
}

// 下拉弹窗
.job_list ::v-deep .van-dropdown-menu__bar {
  height: 50px;
  box-shadow: 0px 0px 0px rgba(255, 255, 255, 0);
}

.job_list ::v-deep .van-dropdown-menu__item {
  width: 100px;
  margin-right: 20px;
}

.swiper {
  border-radius: 10px;
  padding: 0px 2px;
  overflow: hidden;
  img {
    width: 100%;
    display: block;
  }
  .custom-indicator {
    width: 100%;
    position: absolute;
    left: 0px;
    bottom: 0px;
    text-align: center;
    ul {
      display: inline-block;
      margin: 0 auto;
      li {
        display: inline-block;
        width: 6px;
        height: 2px;
        margin: 0px 2px;
        background-color: rgba(255, 255, 255, 0.6);
        &.con {
          background-color: #fff;
        }
      }
    }
  }
}

.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 0px;
  text-align: center;
  background-color: #39a9ed;
}

/* 顶部固定栏目 */
.jobWanted_header {
  position: fixed;
  height: 110px;
  width: 100%;
  background-color: #ffffff;
  z-index: 9999;
  .jobWanted_header_top {
    box-sizing: border-box;
    display: flex;
    height: 50px;
    width: 100%;
    padding: 0 25px;
    justify-content: space-between;
  }
}
.jobWanted_header_top {
  height: 52px;
  line-height: 52px;
  .jobWanted_title {
    h2 {
      height: 52px;
      line-height: 52px;
      font-size: 22px;
      color: #2a2a2a;
      font-weight: 600;
    }
  }
}
.jobWanted_btn {
  display: flex;
  width: 65px;
  height: 50px;
  justify-content: flex-end;
  align-items: center;
  .btn_one {
    position: relative;
    width: 20px;
    height: 20px;
    // margin-right: 24px;
    background: url(../assets/imgs/添加.png) no-repeat center center;
    background-size: 100%;
    // &::after {
    //   content: "";
    //   display: block;
    //   position: absolute;
    //   width: 2px;
    //   height: 14px;
    //   top: 0px;
    //   bottom: 0px;
    //   right: -10px;
    //   margin: auto 0;
    //   background-color: #f4f4f4;
    // }
  }
  // .btn_tow {
  //   width: 22px;
  //   height: 22px;
  //   background: url(../assets/imgs/search.png) no-repeat center center;
  //   background-size: 100%;
  // }
}
.jobWanted_btn .btn_one a,
.jobWanted_btn .btn_tow a {
  display: block;
  width: 100%;
  height: 100%;
}
.jobWanted_header_bottom {
  display: flex;
  padding: 0px 25px;
  justify-content: space-between;
  align-items: center;
}
.job_bottom_lf,
.job_list {
  display: flex;
}
.job_list {
  .job_item {
    position: relative;
    margin: 0px 14px;
    height: 60px;
    line-height: 60px;
    &::after {
      content: "";
      display: block;
      position: absolute;
      width: 8px;
      height: 6px;
      background: url(../assets/imgs/src_assets_img_cvs_rectanglebottom.png)
        no-repeat center center;
      background-size: 100%;
      top: 1px;
      bottom: 0px;
      right: -12px;
      margin: auto 0;
    }
    span {
      display: block;
      width: 100%;
      height: 100%;
      color: #6d6d6d;
    }
  }
}
.job_bottom_lf {
  h3 {
    color: #cecece;
    font-size: 18px;
    height: 60px;
    line-height: 60px;
    margin-right: 27px;
    font-weight: 800;
    &:nth-last-child(1) {
      margin: 0px;
    }
    &.con {
      position: relative;
      color: #434343;
      font-weight: 800;
      &::after {
        content: "";
        display: block;
        position: absolute;
        width: 18px;
        height: 3px;
        background-color: #ff4a23;
        right: 0px;
        left: 0px;
        bottom: 8px;
        margin: 0 auto;
      }
    }
  }
}
.jobWanted_header_ti {
  height: 110px;
}

/* 广告1 */
.jobW_advertising {
  box-sizing: border-box;
  padding: 0 16px;
  width: 100%;
  margin-top: 30px;
  border-radius: 10px;
  overflow: hidden;
}
.jobW_imgs {
  box-sizing: border-box;
  padding: 0 5px;
  width: 100%;
  overflow: hidden;
  //   background: url(../assets/imgs/广告2.jpg) no-repeat center center;
  background-size: 110%;
}

/* 选项卡 */
.jobW_card {
  box-sizing: border-box;
  padding: 0px 16px;
  margin-top: 10px;
}
.jobW_card_title {
  width: 100%;
  background-color: #fff;
  border-radius: 10px;
  overflow: hidden;
  .title_text {
    display: flex;
    box-sizing: border-box;
    padding: 0 18px;
    margin-top: 8px;
    justify-content: space-between;
    h3 {
      width: 60%;
      display: block;
      height: 40px;
      line-height: 40px;
      font-size: 16px;
      font-weight: 800;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .paric {
      position: relative;
      // width: 27%;
      display: block;
      // height: 40px;
      line-height: 40px;
      font-size: 16px;
      font-weight: 800;
      color: #f95d39;
    }
  }
}
.title_text {
  .state {
    position: absolute;
    box-sizing: border-box;
    height: 14px;
    left: -35px;
    top: -10px;
    bottom: 0px;
    margin: auto 0;
    border: 1px solid #5c94f5;
    h4 {
      font-size: 12px;
      display: block;
      height: 14px;
      line-height: 11px;
      color: #5c94f5;
      transform: scale(0.6);
    }
  }
}
.jobW_card_list {
  display: flex;
  padding-left: 18px;
  margin-bottom: 16px;
  .jobW_card_item {
    height: 22px;
    line-height: 22px;
    display: block;
    font-size: 12px;
    padding: 5px 6px 4px;
    margin-right: 6px;
    border-radius: 5px;
    background-color: #f6f6f6;
  }
}
.jobW_company {
  display: flex;
  padding: 0px 16px;
  margin-bottom: 22px;
  justify-content: space-between;
  .company_mes {
    position: relative;
    margin-left: 36px;
    display: flex;
    &::before {
      content: "";
      display: block;
      position: absolute;
      width: 25px;
      height: 25px;
      top: 0px;
      bottom: 0px;
      margin: auto 0px;
      left: -30px;
      background: url(../assets/imgs/量子恒道.png) no-repeat center center;
      background-size: 100%;
    }
    .compay_items {
      font-size: 14px;
      margin-right: 15px;
    }
  }
  .place {
    color: #cecece;
    font-size: 14px;
  }
}
/* 底部固定栏目 */
.shr {
  height: 52px;
}
.shroud {
  position: fixed;
  bottom: 0px;
  right: 0px;
  left: 0px;
  .shroudPanel {
    display: flex;
    height: 52px;
    justify-content: space-between;
    text-align: center;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
    background-color: #ffffff;
    & > .icon {
      margin-right: 17px;
      box-sizing: border-box;
      position: relative;
      margin-left: 17px;
      height: 52px;
      padding-top: 4px;
      flex: 1;
      .iconrun {
        display: block;
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 999;
      }
      .img {
        img {
          width: 26px;
          height: 26px;
        }
      }
    }
    .icon {
      & > span {
        display: block;
        font-size: 9px;
        color: #5d5d5d;
        height: 10px;
        line-height: 10px;
      }
      & > .con {
        color: #555565;
      }
    }
  }
}
.message {
  position: relative;
  .list_message {
    position: absolute;
    width: 19px;
    height: 30px;
    top: 0px;
    left: 0px;
    right: 0px;
    margin: 0 auto;
  }
  .message_sum {
    position: absolute;
    box-sizing: border-box;
    width: 28px;
    height: 18px;
    background-color: #ff522d;
    border: 1px solid #fb4d2a;
    font-size: 12px;
    color: #fff;
    border-radius: 10px;
    top: -5px;
    right: -20px;
  }
}
.list_message {
  .item_message {
    display: block;
    float: left;
    width: 3px;
    height: 3px;
    margin-top: 11px;
    margin-left: 3px;
    background-color: #fff;
  }
}
</style>